perf + seo: 15x faster lookup SDK, sync all AI discovery surfaces to the real 11-tool MCP registry#127
Merged
Conversation
- generator/lookup.py: cache compiled regexes alongside the canon list, invalidated by list identity so tests that swap _CANONS_CACHE still rebuild correctly. With 2339 canons the stdlib re cache (512 entries) thrashed, recompiling every pattern on every lookup_all() call: ~260ms -> ~17ms per lookup after warm-up. Invalid regexes now warn once at compile time instead of on every call. - tests: add regression tests for cache reuse, invalidation on canon swap, and invalid-regex skipping. - CLAUDE.md: MCP server docs said 8 read-only tools; server exposes 11 (list_errors_by_country, get_country_summary, report_outcome), and report_outcome writes to data/outcomes/. - scripts/collect_github_signals.py: fix ruff E741 (ambiguous name 'l'). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BgnR294a753jA4h4yDbJT9
AI agents were being steered by stale metadata: most discovery files
advertised only 8-10 MCP tools while the server exposes 11, and none of
them surfaced the country-scoped knowledge (the dataset's key
differentiator vs generic LLM answers).
- Add MCP_TOOL_NAMES to generator/build_site.py as the single source of
truth for every emitted discovery surface: llms.txt, ai-plugin.json,
agent.json (A2A), mcp.json, server-card.json, site CLAUDE.md,
.cursorrules/.windsurfrules/.clinerules, site AGENTS.md, and the
homepage ai-summary block.
- agent.json: add list-errors-by-country, get-country-summary, and
report-outcome skills (8 -> 11).
- server-card.json: add report_outcome, sync version to 1.6.0 (matches
mcp/server.py serverInfo).
- Site config files now advertise country endpoints
(/api/v1/countries.json, /api/v1/country/{cc}.json) and per-domain
context slices (/llms-full-{domain}.txt) so agents can pull bounded,
targeted context instead of skipping the 2MB full dump.
- Homepage ai-summary: add COUNTRY_INDEX/COUNTRY_PATTERN lines and
render the tool list from mcp_tools instead of a hardcoded 8.
- Root AGENTS.md: add the two missing country tools.
- tests: assert MCP_TOOL_NAMES == mcp/server.py TOOLS so the discovery
surfaces can never drift from the real registry again.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BgnR294a753jA4h4yDbJT9
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Project-wide review with two focused improvements: a lookup SDK performance fix and a full sync of every AI-agent discovery surface so agents are steered to the real capabilities of this project.
1. Lookup SDK: pre-compile canon regexes (~15x faster)
generator/lookup.pyrecompiled all 2,339 canon regexes on everylookup_all()call — the stdlibremodule caches only 512 patterns internally, so the cache thrashed on each pass (~260ms per lookup). The MCP server (mcp/server.py) and Vercel endpoint (api/mcp.py) already pre-compile; the SDK was the only path that didn't._CANONS_CACHEstill rebuild correctly).batch_lookupof 10 messages: ~2.6s → ~0.4s.2. AI discovery surfaces: fix 8/10-tool drift, advertise country knowledge
The MCP server exposes 11 tools, but most discovery files advertised 8–10, and none surfaced the country-scoped dataset (the project's key differentiator):
MCP_TOOL_NAMESconstant ingenerator/build_site.pyis the single source of truth for:llms.txt,.well-known/ai-plugin.json,.well-known/agent.json(A2A),.well-known/mcp.json,.well-known/mcp/server-card.json, siteCLAUDE.md,.cursorrules/.windsurfrules/.clinerules, siteAGENTS.md, and the homepageai-summaryblock.agent.json: addslist-errors-by-country,get-country-summary,report-outcomeskills (8 → 11).server-card.json: addsreport_outcome; version synced to 1.6.0 (matchesmcp/server.pyserverInfo)./api/v1/countries.json,/api/v1/country/{cc}.json) and per-domain context slices (/llms-full-{domain}.txt) so agents can pull bounded, targeted context.ai-summary: addsCOUNTRY_INDEX/COUNTRY_PATTERNlines; tool list rendered from the constant.AGENTS.mdandCLAUDE.mdtool lists corrected to 11.3. Housekeeping
scripts/collect_github_signals.py—ruff check .is now fully clean.Test plan
ruff check .— cleanpython -m pytest tests/— 300 passed (296 existing + 4 new)MCP_TOOL_NAMES == mcp/server.py TOOLSdrift-prevention testpython -m generator.validate --data-only— passed (2,339 canons)python -m generator.validate --site-only— passed.well-knownmanifests,llms.txt, and homepage now advertise 11 tools + country endpointspython -m generator.lookup "ModuleNotFoundError..."returns identical matches🤖 Generated with Claude Code
https://claude.ai/code/session_01BgnR294a753jA4h4yDbJT9
Generated by Claude Code